home *** CD-ROM | disk | FTP | other *** search
/ Delphi Magazine Collection 2001 / Delphi Magazine Collection 20001 (2001).iso / DISKS / Issue43 / recalc / CALCTBLS.PAS < prev    next >
Encoding:
Pascal/Delphi Source File  |  1998-12-10  |  1.2 KB  |  51 lines

  1. unit CalcTbls;
  2.  
  3. {$R-,S-,I-,O-,F-,A+,U+,K+,W-,V+,B-,X+,T-,P+,L+,Y+,D+}
  4.  
  5. //  These interposer classes allow CanModify to be overridden so that
  6. //  calculated fields may be edited.  This unit must appear after DBTABLES
  7. //  in the uses clause in each unit where this facility is required.
  8.  
  9. interface
  10.  
  11. uses
  12.   Classes, DB, DBTables;
  13.  
  14. type
  15.   TTable = class(DBTables.TTable)
  16.   protected
  17.     procedure DoAfterScroll; override;
  18.     procedure ClearCalcFields (Buffer : PChar); override;
  19.   end;
  20.  
  21. implementation
  22.  
  23. {****************************************************************
  24. * TABLE                                                         *
  25. ****************************************************************}
  26.  
  27. procedure TTable.DoAfterScroll;
  28. var
  29.   OldState : TDataSetState;
  30.   I        : smallint;
  31. begin
  32.   OldState := SetTempState (dsNewValue);
  33.   try
  34.     inherited;
  35.   finally
  36.     RestoreState (OldState);
  37.     for I := 0 to FieldCount-1
  38.     do if Fields [I].FieldKind = fkCalculated
  39.        then DataEvent (deFieldChange,longint(Fields [I]));
  40.   end;
  41. end;
  42.  
  43. procedure TTable.ClearCalcFields (Buffer : PChar);
  44. begin
  45. //  prevents calculated fields from being wiped if reqd
  46.   if AutoCalcFields
  47.   then inherited;
  48. end;
  49.  
  50. end.
  51.